﻿using System.Collections.Generic;
using Runtime.Services.Battle;

namespace Runtime.Models {

    public interface IDFR_BattleModelsTD : IDFR_BattleModelsBase {

        /// <summary>
        /// 单元格数据集
        /// </summary>
        new IDFR_ReadOnlyBattleCellDictionaryModelTD CellDictionary { get; }

        /// <summary>
        /// 进攻方数据集
        /// </summary>
        new IDFR_ReadOnlyBattleAttackSourceDictionaryModelTD AttackSourceDictionary { get; }

        /// <summary>
        /// 敌方数据集
        /// </summary>
        new IDFR_ReadOnlyBattleAttackTargetDictionaryModelTD AttackTargetDictionary { get; }

        DFR_BattleGridOption GridOption { get; }

        IReadOnlyList<DFR_BattleCellAxis> Way { get; }

        bool IsStaticObstacle(DFR_BattleCellAxis axis);
    }

    [Implement(typeof(IDFR_BattleModelsTD))]
    [Implement(typeof(IDFR_BattleModelsBase))]
    public class DFR_BattleModelsTD : DFR_BattleModelsBase, IDFR_BattleModelsTD {

        public new IDFR_ReadOnlyBattleCellDictionaryModelTD CellDictionary => (IDFR_ReadOnlyBattleCellDictionaryModelTD)base.CellDictionary;

        public new IDFR_ReadOnlyBattleAttackSourceDictionaryModelTD AttackSourceDictionary => (IDFR_ReadOnlyBattleAttackSourceDictionaryModelTD)base.AttackSourceDictionary;

        public new IDFR_ReadOnlyBattleAttackTargetDictionaryModelTD AttackTargetDictionary => (IDFR_ReadOnlyBattleAttackTargetDictionaryModelTD)base.AttackTargetDictionary;

        public DFR_BattleGridOption GridOption { get; protected set; }

        public IReadOnlyList<DFR_BattleCellAxis> Way { get; protected set; }

        protected HashSet<DFR_BattleCellAxis> m_StaticObstacleSet;

        public bool IsStaticObstacle(DFR_BattleCellAxis axis) => m_StaticObstacleSet.Contains(axis);

        protected override void Dispose() {
            Way = null;
            m_StaticObstacleSet = null;
            base.Dispose();
        }
    }
}
